<template>
	<view class="p20">
		<view class="pt40 flex row-center">
			<imgList hide @setImg="e=>{form.avatar_img=e.path,form.avatar=e.id}" ref="img" />

			<!-- <u-avatar :src="form.avatar_img||form.avatar"  size="130" show-level
				level-icon="camera-fill"></u-avatar> -->

			<button class="u-reset-button" type="default" open-type="chooseAvatar" @click="upImg"
				@chooseavatar="onChooseAvatar">
				<view class="pl20 pr20">
					<u-avatar :src="form.avatar_img||form.avatar" size="130" show-level level-icon="camera-fill">
					</u-avatar>
				</view>
			</button>
		</view>
		<view class="mt70 bg-fff radius20 pl20 pr20">
			<!-- <view class="flex pt20 pb20 border-b" 
				v-for="(item,index) in list" :key="index">
				<view class="color-666 ">{{item.name}}</view>
				<u-input v-model="form[item.fidle]" :disabled="item.disabled" :type="item.inputType||'text'"
					:placeholder="`请输入`+item.name" inputAlign="right" :clearable="false" class="tr flex1 ml20" />
				<u-icon name="arrow-right" class="ml10 pe-none" v-if="item.right" />
			</view> -->
			<view class="flex pt20 pb20 border-b">
				<view class="color-666 ">姓名</view>
				<u-input v-model="form.name" @blur="e=>form.name=e" type="nickname" placeholder="请输入姓名"
					inputAlign="right" :clearable="false" class="tr flex1 ml20" />
				<u-icon name="arrow-right" class="ml10 pe-none" />
			</view>
		</view>
		<view class="h120"></view>
		<view class="pf bottom0 left0 bg-fff w-max">
			<view class="p20">
				<u-button type="warning" ripple @click="submit">保存修改</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
						name: '姓名',
						fidle: 'name',
						right: true,
						identityHide: [''],
						inputType: 'nickname'
					},
					// {
					// 	name: '年龄',
					// 	fidle: 'age',
					// 	right: true,
					// 	inputType: 'number',
					// 	identityHide: ['organ'],
					// }, {
					// 	name: '身份证号',
					// 	fidle: 'card_no',
					// 	right: true,
					// 	identityHide: ['organ'],
					// }, {
					// 	name: '手机号码',
					// 	fidle: 'mobile',
					// 	disabled: true,
					// 	identityHide: [''],
					// }, {
					// 	name: '护龄',
					// 	fidle: 'service_year',
					// 	right: true,
					// 	inputType: 'number',
					// 	identityHide: ['organ'],
					// }, {
					// 	name: '家庭住址',
					// 	fidle: 'address',
					// 	right: true,
					// 	identityHide: [''],
					// }, {
					// 	name: '个人简介',
					// 	fidle: 'profile',
					// 	right: true,
					// 	identityHide: [''],
					// },
				],
				form: {
					avatar: "", //	整型	非必填	-	-	头像
					avatar_img: "", //	整型	非必填	-	-	头像
					name: '',
				}
			};
		},
		onLoad() {
			for (let key in this.form) {
				this.form[key] = this.$user[key]
			}
		},
		methods: {
			submit() {
				this.$request('/member/my/editInfo', this.form).then(res => {
					this.$msg(res.msg)
					this.$getUser()
					setTimeout(this.$navBack, 800)
				})
			},
			onChooseAvatar(e) {
				this.$refs.img.uploadFile(e.detail.avatarUrl, 'setImg')
			},
			upImg() {
				// #ifndef MP-WEIXIN
				this.$refs.img.upImg('setImg')
				// #endif
			}
		}
	}
</script>

<style lang="scss">

</style>
